Repository navigation
src: enable V8's WASM trap handlers - #27246
Conversation
commented
Apr 15, 2019
2aa0fb8 to
5402f28
Compare
commented
Apr 15, 2019
|
My gut feeling would be that @ofrobots’s comment in #14927 (comment) is a good approach – using our own signal handler, and providing a public C++ API for forwarding that to addons/embedders? That would mean that those would not have to carry the responsibility of integrating with V8’s APIs. I’d say this is semver-major because of the conflicts with existing published versions of |
|
@addaleax we already have we'll need to add a bunch of platform specific switches for calling TryWasmTrapHanderPosix vs TryWasmTrapHandlerWin but if that complexity is okay then we can go for it. |
ea0ade9 to
ab9a5b7
Compare
commented
Apr 15, 2019
|
@addaleax set up to use RegisterSignalHandler, unfortunately we only have that for posix atm, so maybe we can expand to win in the future? (although i don't think people on windows are expecting great performance anyway 🤷♂️) |
7c3fee8 to
0865e93
Compare
commented
Apr 15, 2019
|
@devsnek Yeah, we’d need to find some common API (or expose 2 variants) for both Windows and POSIX; and maybe find some API constraints, e.g. what happens if it is called multiple times, is the registering function threadsafe, etc. and document that |
0865e93 to
a244828
Compare
There was a problem hiding this comment.
Can you put this into the per_process namespace and make it static?
commented
Apr 16, 2019
|
Sorry, I forgot to mention something important: you must re-raise the SIGSEGV when V8 doesn't handle it and there's no other handler for it. |
94fbe09 to
d05e688
Compare
d05e688 to
c7d11fe
Compare
There was a problem hiding this comment.
Not a blocker, just an observation, but I expect that's no longer relevant for the freebsd versions we support.
There was a problem hiding this comment.
@nodejs/platform-freebsd can anyone confirm or deny?
There was a problem hiding this comment.
@bnoordhuis do you know if there's any more background/detail on the issue?
@kostikbel any insight? The referenced comment is:
// FreeBSD has a nasty bug with SA_RESETHAND reseting the SA_SIGINFO, that is
// in turn set for a libthr wrapper. This leads to a crash.
// Work around the issue by manually setting SIG_DFL in the signal handler
There was a problem hiding this comment.
From my copy of POSIX 1003.1-2017 AKA SUSv7:
SA_RESETHAND If set, the disposition of the signal shall be reset to SIG_DFL and the SA_SIGINFO flag shall be cleared on entry to the signal handler.
And we do exactly that. Am I reading right that this behavior causes some troubles, when combined with libthr ? Can you give a minimal example ?
There was a problem hiding this comment.
@emaste @kostikbel The bug report is nodejs/node-v0.x-archive#9326, triage starts in nodejs/node-v0.x-archive#9326 (comment).
I'm reasonably sure that bug was fixed in fbsd 11 but you probably know for sure, @kostikbel, since you authored the fix.
There was a problem hiding this comment.
Ok, so should this comment (and possibly some code) removed ? Since I believe all supported FreeBSD versions have the SA_RESETHAND | SA_SIGINFO fix.
There was a problem hiding this comment.
That sounds about right (removing code & comment.) I've opened #27515 to track it.
|
@bnoordhuis do you know why this compiles fine on macos but has issues finding those atomic symbols on the linux build? |
commented
May 1, 2019
|
Reproducing here because scrolling trough Travis really is quite horrid: DetailsI'm going to guess that gcc doesn't know how to lower the If you switch to function pointers, the problem should hopefully go away. |
commented
May 1, 2019
|
Or maybe link to |
commented
May 16, 2019
This uses SIGSEGV handlers to catch WASM out of bound (OOB) memory accesses instead of inserting OOB checks inline, resulting in a 25%-30% speed increase. Note that installing a custom SIGSEGV handler will break this, resulting in potentially scary behaviour. Refs: nodejs#14927 PR-URL: nodejs#27246 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
3cdac98 to
70c7686
Compare
commented
May 16, 2019
|
landed in 70c7686 |
commented
May 21, 2019
commented
May 21, 2019
commented
May 21, 2019
commented
Sep 9, 2019
|
Notable change: This speeds up memory operations for WASM by around 25-30%. However, native code must now install the SIGSEGV signal handlers using node::RegisterSignalHandler. |
This uses SIGSEGV handlers to catch WASM out of bound (OOB) memory
accesses instead of inserting OOB checks inline, resulting in a 25%-30%
speed increase.
Note that installing a custom SIGSEGV handler will break this, resulting
in potentially scary behaviour. Users should use node::RegisterSignalHandler instead.
Refs: #14927
Closes #14927
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes